package com.ruoyi.system.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ExecutionTimeLogger {
	
	@Around("execution(* *(..)) && within(com.ruoyi.system.service..*)")
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long startTime = System.currentTimeMillis();
        System.out.println("Method " + joinPoint.getSignature().toShortString() + " started.");
        Object result = joinPoint.proceed();
        long endTime = System.currentTimeMillis();
        System.out.println("Method " + joinPoint.getSignature().toShortString() + " finished. Execution time: " + (endTime - startTime) + " milliseconds.");
        return result;
    }
	
}
